﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication2
{
    public partial class WebForm2 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["userName"] == null || Response.Cookies["password"] == null)
            {
                Response.Redirect("WebForm1.aspx");
            }
            if (Application["chatRoom"] == null)
            {
                Application["chatRoom"] = new Panel();
            }
            Panel1.Controls.Add((Panel)Application["chatRoom"]);
        }

        protected void btnSend_Click(object sender, EventArgs e)
        {
            Literal literal = new Literal();

            literal.Text = $"{Session["userName"].ToString()} {DateTime.Now.ToString()}:" +
                $"{tbxInfo.Text}";
            ((Panel)Application["chatRoom"]).Controls.Add(literal);
        }

        protected void btnReflesh_Click(object sender, EventArgs e)
        {
            Page_Load(sender,e);
        }

        protected void btnExit_Click(object sender, EventArgs e)
        {
            Session.Abandon();
            Response.Redirect("WebForm1.aspx");
        }
    }
}